package util;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

public class FacesUtil {

	public static Object getSessionMapValue(String key) {		
        return FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get(key);
    }
	
	public static void setSessionMapValue(String key, Object value){
		FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(key, value);
	}
	
	public static void addErrorMessage(String message){
		FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, message, message));
	}
	
	public static String getMessageResourceString(String resourceName){
		return Util.getMessageResourceString(FacesContext.getCurrentInstance().getApplication().getMessageBundle(), resourceName, null, 
				FacesContext.getCurrentInstance().getViewRoot().getLocale());
	}
	
}
